home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / WillowWisp.dxr / Internal_3_stock cards.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  1.9 KB  |  59 lines

  1. property spriteNum
  2. global stock, tableau
  3.  
  4. on beginSprite me
  5.   stock = new(script("card pile"))
  6.   stock.cards = shuffle()
  7. end
  8.  
  9. on shuffle me
  10.   unshuffled = []
  11.   shuffled = []
  12.   repeat with rank in ["ace", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king"]
  13.     repeat with suit in ["hearts", "diamonds", "clubs", "spades"]
  14.       unshuffled.add([#rank: rank, #suit: suit])
  15.     end repeat
  16.   end repeat
  17.   repeat while unshuffled.count > 0
  18.     temp = unshuffled[random(unshuffled.count)]
  19.     shuffled.add(temp)
  20.     unshuffled.deleteOne(temp)
  21.   end repeat
  22.   return shuffled
  23. end
  24.  
  25. on mouseDown me
  26.   if sprite(spriteNum).member.name = "backofcard" then
  27.     repeat with num in [12, 28, 44, 60, 76, 92, 108]
  28.       if stock.cards.count = 0 then
  29.         exit repeat
  30.       end if
  31.       puppetSound(3, member("deal card", "100GPak Generic SFX"))
  32.       if tableau[sprite(num).row].getcardcount() > 0 then
  33.         tempnum = tableau[sprite(num).row].getlastcard().spnum + 1
  34.         sprite(tempnum).member = member(stock.cards[1].rank & "_" & stock.cards[1].suit, "playing cards")
  35.         stock.cards.deleteAt(1)
  36.         tableau[sprite(num).row].addCard(tableau[sprite(num).row].getlastcard().spnum + 1)
  37.       else
  38.         sprite(num).member = member(stock.cards[1].rank & "_" & stock.cards[1].suit, "playing cards")
  39.         stock.cards.deleteAt(1)
  40.         tableau[sprite(num).row].addCard(num)
  41.       end if
  42.       updateStage()
  43.     end repeat
  44.     repeat with u in [26, 42, 58, 74, 90, 106, 122]
  45.       if tableau[sprite(u).row].getcardcount() = 0 then
  46.         temp = [12, 28, 44, 60, 76, 92, 108]
  47.         temp2 = [26, 42, 58, 74, 90, 106, 122]
  48.         ass = temp[temp2.findPos(u)]
  49.         sprite(u).loc = sprite(ass).location
  50.       end if
  51.       sprite(u).loc = tableau[sprite(u).row].getlastcard().location
  52.     end repeat
  53.     if stock.cards.count = 0 then
  54.       sprite(spriteNum).member = member("empty", "playing cards")
  55.       checklose()
  56.     end if
  57.   end if
  58. end
  59.